package cn.stimd.spring.aop.framework.autoproxy;

import cn.stimd.spring.beans.factory.config.BeanDefinition;
import cn.stimd.spring.beans.factory.config.ConfigurableBeanFactory;

/**
 * 使用Spring内置的Advisor，排除自定义的Advisor
 * <p>
 * Created by Stimd
 * 项目地址：https://gitee.com/stimd/spring-wheel
 * 公众号：Java编程探微
 */
public class InfrastructureAdvisorAutoProxyCreator extends AbstractAdvisorAutoProxyCreator {

    @Override
    protected boolean isEligibleAdvisorBean(String beanName) {
        ConfigurableBeanFactory beanFactory = (ConfigurableBeanFactory) getBeanFactory();
        return beanFactory.containsBeanDefinition(beanName)
                && beanFactory.getBeanDefinition(beanName).getRole() == BeanDefinition.ROLE_INFRASTRUCTURE;
    }
}
